from rest_framework import serializers

from areas.models import Area

class AreaSerializer(serializers.ModelSerializer):
    '''省级序列化器类'''
    class Meta:
        model = Area
        fields = ('id','name')


class SubAreaSerializer(serializers.ModelSerializer):
    '''下级地区序列化器类'''
    subs = AreaSerializer(label='下级地区',many=True) # 嵌套序列化3种

    class Meta:
        model = Area
        fields = ('id', 'name', 'subs')